<template>
  <div class="line-echarts">
    <base-echarts :options="options" :canvas-height="height" />
  </div>
</template>

<script setup lang="ts">
import type { EChartsOption } from 'echarts';

interface IProps {
  height?: string;
  labels: string[];
  values: number[];
}

const props = withDefaults(defineProps<IProps>(), {
  height: '400px'
});

const options: EChartsOption = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      label: {
        backgroundColor: '#6a7985'
      }
    }
  },
  legend: {},
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: [
    {
      type: 'category',
      boundaryGap: false,
      data: props.labels
    }
  ],
  yAxis: [
    {
      type: 'value'
    }
  ],
  series: [
    {
      name: '分类销量统计',
      type: 'line',
      stack: '总量',
      areaStyle: {},
      emphasis: {
        focus: 'series'
      },
      data: props.values
    }
  ]
};
</script>

<style scoped lang="scss">
.line-echarts {
}
</style>
